home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / kiss-0.11 / kiss-0 / kiss / src / dosetenv.c < prev    next >
C/C++ Source or Header  |  1995-03-23  |  657b  |  30 lines

  1. #include "kiss.h"
  2.  
  3. int dosetenv (Stringstack s)
  4. {
  5.     register int
  6.     i;
  7.  
  8.     if (getopt (s.nstr, s.str, "h") != -1)
  9.     {
  10.     warning ("Bad commandline.\n"
  11.          "Usage: setenv -h         this text\n"
  12.          "       setenv VAR value  set enviroment variable to value\n"
  13.          "       VAR=value         set environment "
  14.                     "variable to value\n");
  15.     return (1);
  16.     }
  17.  
  18.     if (s.nstr != 3)
  19.     return (warning ("command needs VARIABLE and value\n"));
  20.  
  21.     for (i = 0; i < strlen (s.str [1]); i++)
  22.     if (! isupper (s.str [1][i]))
  23.         return (warning ("variable \"%s\" is not all upper case\n",
  24.                  s.str [1]));
  25.  
  26.     addtoenv (s.str [1], s.str [2]);
  27.  
  28.     return (0);
  29. }
  30.